<template>
	<view class="user clearfix  hv100 ">
		<cu-custom bgColor="bg-white" isBack>
			<block slot="content">充值</block>
		</cu-custom>
		<view class="flex flex-direction bg-white px15 mt5">
			<view class="py10">充值金额</view>
			<view class="flex align-center py15">
				<text class="f26">￥</text>
				<input v-model="money" class="ml10" type="number" />
			</view>
			<view class="payline" v-if="type=='1'"></view>
			<view class="flex align-center justify-between py15" v-if="type=='1'">
				<text>可得粮票</text>
				<text class="text-red">{{huoqu}} 粮票</text>
			</view>
		</view>
		<view class="flex flex-direction bg-white px15 mt10">
			<view class="py10">选择充值方式</view>
			<view class="payline"></view>
			<view class="mt15 flex align-center" @click="radio=1">
				<image src="/static/wallet/choice.png" class="block20" v-if="radio==1" mode=""></image>
				<image src="/static/wallet/nochoice.png" class="block20" v-else mode=""></image>
				<image src="/static/wallet/zfb.png" class="block25 ml15" mode=""></image>
				<text class="ml10">支付宝</text>
			</view>
			<view class="mt15 pb15 flex align-center" @click="radio=2">
				<image src="/static/wallet/choice.png" class="block20" v-if="radio==2" mode=""></image>
				<image src="/static/wallet/nochoice.png" class="block20" v-else mode=""></image>
				<image src="/static/wallet/wx.png" class="block25 ml15" mode=""></image>
				<text class="ml10">微信</text>
			</view>
		</view>
		<view class="red-button discenter" @click="pay">确认充值</view>
	</view>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
	data() {
		return {
			money:'',
			radio:1,
			type:'',
			bili:''
		}
	},
	onLoad(e) {
		this.type=e.type
		if(this.type=='1'){
			this.getData()
		}
	},
	computed:{
		huoqu(){
			if(this.money!=''&&this.money!=0){
				return this.money*this.bili
			}else{
				return 0
			}
		}
	},
	methods: {
		async getData() {
			let {
				data: {chongzhiBl}
			} = await this.$http.post('wallet.yidourechargepage', {}, { tipConfig: { storeBlock: true } })
			this.bili = chongzhiBl
		},
		async pay(){
			if(this.money==''||this.money==0){
				uni.showToast({
					title:'轻输入正确的充值金额',
					icon:'none'
				})
				return false
			}
			// let { data } = 	await this.$http.post('wallet.yuerecharge', {chongNum:this.money}, {
			// 	custom: {tipConfig: { storeLoading: true, isSuccessTip: true, isSuccessBack: true, navigateBack: 1 }}
			// })
		}
	}
}
</script>

<style lang="less">
.payline{
	width: 100%;
	height: 1rpx;
	background-color: #F2F2F2;
}
.red-button{
	width: calc(100% - 60rpx);
	margin-left: 30rpx;
	height: 90rpx;
	border-radius: 10rpx;
	background-color: #D73329;
	color: #FFFFFF;
	margin-top:80rpx ;
}
</style>
